define(function(require, exports, module) {
	"use strict";

	var baseService = require('Base_Service');
	// 控制器名
	exports.controller = "Account";
	
	/* 注册用户 */
	exports.register = function(data ,success) {
		return baseService.post(
			baseService.getApiUrl(exports.controller, "Register"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	};
	
	/* 修改密码 */
	exports.change = function(data ,success) {
		return baseService.post(
			baseService.getApiUrl(exports.controller, "UpdatePwd"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	};
	
	/* 修改城市 */
	exports.setCity = function(data ,success) {
		return baseService.post(
			baseService.getApiUrl(exports.controller, "SetCity"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	};
	
	/**
	 * 用户登录
	 * @param {Object} data 登录数据
	 * @param {Object} success 成功后的处理
	 */
	exports.login = function(data , success){
		return baseService.post(
			baseService.getApiUrl(exports.controller, "Login"),
			data,
			function(retval) {
				baseService.saveToken(retval.Token);
				baseService.saveUser(retval.User);
				baseService.saveCoach(retval.Coach);
				baseService.saveType(retval.Type);
				success && success(retval);
			}
		);
	}
});